Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@commodo/name
Advanced tools
Decorates a function (and its instances) with a name, that can be used for various purposes.
Decorates a function (and its instances) with a name, that can be used for various purposes.
For example, the @commodo/fields-storage
package relies on the name in order to determine the database table in which the data will be saved.
import { withName } from "@commodo/name";
import { compose } from "ramda";
const User = compose(
withName("User"),
(...)
)();
const Company = compose(
withName("Company"),
(...)
)();
You can then use the hasName
and getName
functions in order to determine if a name was assigned to the passed value, or to get the actual name that was assigned, respectively.
import { withName, hasName, getName } from "@commodo/name";
import { compose } from "ramda";
// A function with a name assigned.
const User = compose(
withName("User"),
(...)
)();
// A function without a name assigned.
const Unknown = compose(
// Name not assigned.
// withName("Unknown"),
(...)
)();
console.log(hasName(User)); // true
console.log(getName(User)); // "User"
// The Unknown function doesn't have a name assigned.
console.log(hasName(Unknown)); // false
console.log(getName(Unknown)); // ""
// Also works on function instances.
const user = new User();
console.log(hasName(user)); // true
console.log(getName(user)); // "User"
const unknown = new Unknown();
console.log(hasName(unknown)); // false
console.log(getName(unknown)); // ""
withName(name: string): Function
Decorates a function (and its instances) with a name.
hasName(value: any): boolean
Checks if the passed value has a name assigned via the withName
.
getName(value: any): string
Returns a name assigned to the passed value. Returns empty string if none assigned.
FAQs
Decorates a function (and its instances) with a name, that can be used for various purposes.
The npm package @commodo/name receives a total of 565 weekly downloads. As such, @commodo/name popularity was classified as not popular.
We found that @commodo/name demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.